package com.example.kafka.controller;

import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@RestController
public class KafkaController {

    @Resource
    private KafkaTemplate kafkaTemplate;

    @RequestMapping("/send")
    public String send() {
        kafkaTemplate.send("my_test", "data：" + LocalDateTime.now());
        return "success";
    }

}